﻿function changeCheckState() {
    try {
        var frm = document.forms[0];
        var i = 0;
        for (i = 0; i < frm.length; i++) {
            if (frm.elements[i].id.indexOf('chkCheckItem') != -1) {
                if (document.getElementById(frm.elements[i].id) != null) {
                    if (frm.elements[i].checked == false) {
                        frm.elements[i].checked = true;
                    } else {
                        frm.elements[i].checked = false;
                    }
                }
            }
        }
    } catch (err) { }
}

function changeCheckStateItem(id) {
    try {
        var frm = document.forms[0];
        var i = 0;
        for (i = 0; i < frm.length; i++) {
            if (frm.elements[i].id.indexOf(id) != -1) {
                if (document.getElementById(frm.elements[i].id) != null) {
                    if (frm.elements[i].checked == false) {
                        frm.elements[i].checked = true;
                    } else {
                        frm.elements[i].checked = false;
                    }
                }
            }
        }
    } catch (err) { }
}


//function changeCheckState(id) {
//    try {
//        var frm = document.forms[0];
//        var i = 0;
//        for (i = 0; i < frm.length; i++) {
//            if (frm.elements[i].id == id) {
//                var el = frm.elements[i];
//                if (el != null) {
//                    if (el.checked == false) {
//                        el.checked = true;
//                    } else {
//                        el.checked = false;
//                    }
//                }
//            }
//        }
//    } catch (err) { }
//}


function clientActiveTabChanged(sender, args) {
    // see if the table elements for the grids exist yet
//    var isTab0Loaded = $get('<%= ucForumTopics.FindControl("gridViewForumTopics").ClientID %>');
//    var isTab1Loaded = $get('<%= ucForumTemplates.FindControl("gridViewForumTemplates").ClientID %>');
//    var isTab2Loaded = $get('<%= ucForumThreadPosts.FindControl("gridViewThreadPosts").ClientID %>');
//    if (!isTab0Loaded && sender.get_activeTabIndex() == 0) {
//        __doPostBack('btnForumTopicsTrigger', '');
//    }
//    else if (!isTab1Loaded && sender.get_activeTabIndex() == 1) {
//        __doPostBack('btnForumTemplatesTrigger', '');
//    }
//    else if (!isTab2Loaded && sender.get_activeTabIndex() == 2) {
//        __doPostBack('btnForumThreadPostsTrigger', '');
    //    }
    if (sender.get_activeTabIndex() == 0) {
        __doPostBack('btnForumTopicsTrigger', '');
    }
    else if (sender.get_activeTabIndex() == 1) {
        __doPostBack('btnForumTemplatesTrigger', '');
    }
    else if (sender.get_activeTabIndex() == 2) {
        __doPostBack('btnForumThreadPostsTrigger', '');
    }

//    switch (sender.get_activeTabIndex()) {
//        case 0:
//            __doPostBack('btnForumTopicsTrigger', '');
//        case 1:
//            __doPostBack('btnForumTemplatesTrigger', '');
//        case 2:
//            __doPostBack('btnSearchForumThreadsTrigger', '');
//    }

}